<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let obj = {
            'name':'suliang',
            'age':21,
            'gender':'男'
        };
        // console.log(obj.name); //suliang

        //json=>js对象 JSON.parse()
        let obj2 = '{"name":"suliang","age":21, "gender":"男"}'
        // console.log(typeof obj2); //string
        let result = JSON.parse(obj2);
        // console.log(result); //{name: 'suliang', age: 21, gender: '男'}


        //js对象转json JSON.stringify()
        let obj3 ={
            name:'ming',
            age:22,
            gender:'男'
        }
        let result2 = JSON.stringify(obj3);
        console.log(result2,typeof result2);  //{"name":"ming","age":22,"gender":"男"}

    </script>
</body>
</html>